﻿using System;
using System.ComponentModel;
using System.Data;
using System.Linq.Expressions;
using CSW.Framework.Common.Binding.Interfaces;
using CSW.Framework.Linq.QueryModel;

namespace CSW.Framework.Linq
{
    /// <summary>
    /// IBusinessObjectLinq interface.
    /// </summary>
    public interface IBusinessObjectLinq : IBusinessObject
    {
        /// <summary>
        /// Loads the instance from a <see cref="DataRow"/>.
        /// </summary>
        /// <param name="dynamicQuery">The dynamic query.</param>
        /// <param name="dataRow">The <see cref="DataRow"/>.</param>
        void LoadFromDataRow(Query dynamicQuery, DataRow dataRow);

        /// <summary>
        /// Loads the instance from a <see cref="DataRow"/> using a dynamically compiled assembly.
        /// </summary>
        /// <param name="dynamicQuery">The dynamic query.</param>
        /// <param name="dataRow">The <see cref="DataRow"/>.</param>
        void LoadFromDataRowCompiled(Query dynamicQuery, DataRow dataRow);

        /// <summary>
        /// Populates the child binding list.
        /// </summary>
        /// <typeparam name="TSource">The type of the source.</typeparam>
        /// <typeparam name="TEntity">The type of the entity.</typeparam>
        /// <param name="field">The field.</param>
        /// <param name="bindingList">The binding list.</param>
        void PopulateChildBindingList<TSource, TEntity>(Expression<Func<TSource, BindingList<TEntity>>> field, BindingList<TEntity> bindingList)
            where TSource : class, IBusinessObjectLinq
            where TEntity : class, IBusinessObjectLinq;
    }
}
